package vfs.service.impl;

import java.sql.Connection;
import vfs.obj.entity.VFSUser;
import vfs.filter.VFSFilter.VFSFilterOperator;
import vfs.filter.impl.VFSFilterImpl;
import vfs.filter.VFSFilter;
import java.util.Iterator;
import vfs.obj.entity.VFSEntityFactory;
import vfs.obj.entity.impl.VFSEntityFactoryImpl;
import vfs.service.VFSUserService;

/**
 *
 * @author Matthew Eavenson <durandal@uga.edu>
 * 
 */
public class VFSUserServiceImpl implements VFSUserService{
    
    private VFSEntityFactory eFactory;
    
    public VFSUserServiceImpl(Connection conn){
        eFactory = new VFSEntityFactoryImpl(conn);
    }
    
    @Override
    public VFSUser getUser(String uid){
        VFSUser user = null;
        VFSFilter filter = new VFSFilterImpl();
        filter.addConstraint("uid", uid, VFSFilterOperator.EQ);
        Iterator<VFSUser> users = eFactory.findUsers(filter);
        if(users.hasNext()) user = users.next();
        return user;
    }
    
}
